<?php

use Illuminate\Routing\Router;
use Illuminate\Support\Facades\Route;

Route::group([
    'as' => config('inventor.route.prefix') . '.',
], function (Router $router) {
    $router->group(['middleware' => 'menu.group:applies'], function (\Illuminate\Routing\Router $router) {
        $router->get('/', 'HomeController@index')->name('home');
    });
    $router->get('/fjfl', 'EstimateController@index')->name('fjfl');
    $router->get('/fjfl/{id}', 'EstimateController@show')->name('fjfl.show');
    $router->get('/fjfl/{id}/pdf', 'EstimateController@pdf')->name('fjfl.export');

    $router->resource('transverses', 'TransverseController');

    $router->get('patents', 'PatentApplyController@publish');

    $router->get('transactions', 'PatentTransactionController@index');

    $router->resource('bookApplies', 'BookApplyController');
    $router->resource('plantVarieties', 'PlantVarietyController');

    $router->get('agencies', 'AgencyController@index');

    $router->get('documents', 'DocumentController@index');

    $router->group(['prefix' => 'patent', 'as' => 'patent.'], function (\Illuminate\Routing\Router $router) {
        //申请前登记
        $router->resource('applies', 'PatentApplyController');
        $router->get('pg/download/{id}', 'PatentApplyController@download')->name('pg.download');
        $router->get('pg/preview/{id}', 'PatentApplyController@preview')->name('pg.preview');
        $router->get('publish', 'PatentApplyController@publish')->name('publish');
        $router->get('fees', 'PatentFeeController@index')->name('fees.index');
    });
    //不需要权限
    $router->group(['middleware' => 'admin.permission:free'], function (\Illuminate\Routing\Router $router) {
        $router->get('auth/setting', 'UserController@getSetting');
        $router->put('auth/setting', 'UserController@putSetting');

        $router->post('_handle_form_', 'HandleController@handleForm')->name('handle-form');
        $router->post('_handle_action_', 'HandleController@handleAction')->name('handle-action');

        /* @var \Illuminate\Support\Facades\Route $router */
        $router->namespace('\Encore\Admin\Controllers')->group(function ($router) {
            /* @var \Illuminate\Routing\Router $router */
            $router->get('_handle_selectable_', 'HandleController@handleSelectable')->name('handle-selectable');
            $router->get('_handle_renderable_', 'HandleController@handleRenderable')->name('handle-renderable');
        });
    });

    require dirname(__DIR__, 2) . '/routes/file.php';

});
